<%= header %>
<%= boomerangScript %>
<script src="34-xhrs-rt-buffer-full.js" type="text/javascript"></script>
<script>

if ("performance" in window && window.performance.setResourceTimingBufferSize) {
	//
	// There should be 16 requests:
	// * 1 CSS
	// * 6 JS
	// * Main beacon
	// * 4x img.jpg + beacon
	//
	// If we limit to 12 requests, the final two XHRs for img.jpg should not
	// be in the ResourceTiming data
	//
	performance.setResourceTimingBufferSize(12);
}

BOOMR_test.init({
	instrument_xhr: true,
	testAfterOnBeacon: BOOMR.plugins.AutoXHR ? 5 : 1,
	AutoXHR: {
		alwaysSendXhr: true
	},
	afterFirstBeacon: function() {
		if (!BOOMR.plugins.AutoXHR) {
			return;
		}

		setTimeout(function() {
			var xhr1 = new XMLHttpRequest();
			xhr1.open("GET", "/pages/07-autoxhr/support/img.jpg?missing");
			xhr1.send(null);

			xhr1.addEventListener("load", function() {
				setTimeout(function() {
					var xhr2 = new XMLHttpRequest();
					xhr2.open("GET", "/pages/07-autoxhr/support/img.jpg");
					xhr2.send(null);

					xhr2.addEventListener("load", function() {
						setTimeout(function() {
							var xhr3 = new XMLHttpRequest();
							xhr3.open("GET", "/pages/07-autoxhr/support/img.jpg");
							xhr3.send(null);

							xhr3.addEventListener("load", function() {
								setTimeout(function() {
									var xhr4 = new XMLHttpRequest();
									xhr4.open("GET", "/pages/07-autoxhr/support/img.jpg?missing");
									xhr4.send(null);
								}, 1000);
							});
						}, 5000);
					});
				}, 100);
			});
		}, 100);
	}
});
</script>
